import 'package:flutter/material.dart';
import 'package:flutter_learn_demo/define/define_turn_box.dart';

class TurnBoxRoute extends StatefulWidget {

  const TurnBoxRoute({super.key});

  @override
  State createState() => TurnBoxRouteState();

}

class TurnBoxRouteState extends State<TurnBoxRoute> {

  double _turns = 0.0;

  void updateTurns0() {
    setState(() {
      _turns += 0.2;
    });
  }

  void updateTurns1() {
    setState(() {
      _turns -= 0.2;
    });
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.lightBlue,
      child: Center(
        child: Column(
          children: [
             const SizedBox(height: 100,),
             TurnBox(
                 turns: _turns,
                 speeds: 500,
                 child: const Icon(Icons.refresh,size: 50,)
             ),
            const SizedBox(height: 10,),
            TurnBox(
                turns: _turns,
                speeds: 1000,
                child: const Icon(Icons.refresh,size: 150,)
            ),
            const SizedBox(height: 10,),
            ElevatedButton(
                onPressed: () {
                   updateTurns0();
                },
                child: const Text('顺时针旋转1/5')
            ),
            const SizedBox(height: 10,),
            ElevatedButton(
                onPressed: () {
                  print("onPressed--object");
                  updateTurns1();
                },
                child: const Text('逆时针旋转1/5')
            ),
          ],
        ),
      ),
    );
  }
}